package thread;

public class ThreadDemo7 {
    public static void main(String[]args) throws InterruptedException {
        Thread t=new Thread(()->{
            while(true){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("hello Thread!");

            }
        },"这是我的线程");
        t.setDaemon(true);//注意,setDaemon要放在start之前,不然会报错
        t.start();

        Thread.sleep(1000);
        System.out.println(t.getName());
    }
}
